package com.example.caoben_back.contoller;

import com.example.caoben_back.entity.po.ProvinceWeather;
import com.example.caoben_back.entity.vo.Result;
import com.example.caoben_back.service.IProvinceWeatherService;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/weather")
public class WeatherController {
    @Resource
    private IProvinceWeatherService weatherService;

    /**
     * 获取所有省份天气信息（自动处理数据更新）
     */
    @GetMapping(value = "/province/list", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<List<ProvinceWeather>> getAllProvinceWeather() {
        List<ProvinceWeather> data = weatherService.getAllProvinceWeather();
        return Result.success(data);
    }
}